/*
 * @(#)MyProcess.java
 *
 */

package diablo3.process;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * description
 * @author  huangyixiang
 * @version 2012-9-5
 */
public class MyProcess {
	
//	private static final Log LOG = LogFactory.getLog(MyProcess.class);

	private String name;
	private Timer timer;
	
	public MyProcess(String name , String cmdLine){
		this.name = name;
		
		if(!cmdLine.trim().startsWith(name)){
			throw new RuntimeException(cmdLine + "不是" + name + "进程");
		}
		
		String CPUTimeReg = "\\d+\\:\\d+\\:\\d+"; 
		Pattern p = Pattern.compile(CPUTimeReg);
		Matcher m = p.matcher(cmdLine);
		if(!m.find()){
			throw new RuntimeException("没找到CPU时间");
		}
		this.timer = new Timer(m.group());
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Timer getTimer() {
		return timer;
	}
	public void setTimer(Timer timer) {
		this.timer = timer;
	}
	
	@Override
	public String toString() {
		return name + " " +  timer.toString();
	}
}
